#!/bin/sh
#
# Creates a package installer using the contents of 
# /Library/Preferences/ManagedInstalls.plist.
# The purpose of this script is simply to generate a package that will "make
# their computers look like mine" in terms of Munki's behavior.
#
version="${1}"
if [ -z "${version}" ]; then
	version=`date "+%Y.%m.%d"`
fi
manifest=`defaults read /Library/Preferences/ManagedInstalls ClientIdentifier`
manifest=`basename "${manifest}"`
buildDir="/tmp/---building-munki-preferences-${manifest}"

echo "Creating settings for manifest ${manifest}"
mkdir -p "${buildDir}"
cp "/Library/Preferences/ManagedInstalls.plist" "${buildDir}/"

pkgbuild --root "${buildDir}" \
	--identifier edu.denison.munki_settings."${manifest}" \
	--version "${version}" \
	--install-location /Library/Preferences/ \
	munki_settings-"${manifest}".pkg

rm -rf "${buildDir}"
